// 添加，获取时间
const dbConnect=require("../utils/dbConnect")
// 链接数据库
const addInfo =async (data)=>{
    let _sql=`INSERT INTO time (time) VALUES (${new Date(data.date).getTime()})`
     try {
         return await dbConnect(_sql);
     } catch (error) {
         return error;
     }
}

const getInfo=async()=>{
    // ASC 从大到小
    // DESC 从大到大
    let _sql=`SELECT * FROM time WHERE time >${Date.now()} ORDER BY time ASC`;
    // 干掉当前时间戳
    
    // let _sql=`SELECT * FROM time ORDER BY time ASC`;
    
    
    try {
        return await dbConnect(_sql);
    } catch (error) {
        return error;
    }
}

module.exports={addInfo,getInfo};